package com.sjg.sys.service;

import com.sjg.sys.entity.SysDictionary;
import com.sjg.sys.entity.SysUser;
import com.sjg.sys.utils.CommUtil;
import com.sjg.sys.utils.SysConstant;
import com.sjg.sys.utils.TimeUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import com.sjg.sys.dao.SysDictionaryDao;

@Service
public class SysDictionaryService{

    @Resource
    private SysDictionaryDao sysDictionaryDao;

    public int insert(SysDictionary pojo){
        pojo.setId(CommUtil.getPrimaryKey());
        SysUser user= CommUtil.getCurUser();
        pojo.setCreateTime(TimeUtil.getNowTimestamp());
        pojo.setCreatorId(user.getId());
        return sysDictionaryDao.insert(pojo);
    }

    public int insertSelective(SysDictionary pojo){
//        pojo.setId(CommUtil.getPrimaryKey());
//        SysUser user= CommUtil.getCurUser();
//        pojo.setCreateTime(TimeUtil.getNowTimestamp());
//        pojo.setCreatorId(user.getId());
        return sysDictionaryDao.insertSelective(pojo);
    }

    public int insertList(List<SysDictionary> pojos){
        for(SysDictionary dictionary:pojos){
            dictionary.setId(CommUtil.getPrimaryKey());
        }
        return sysDictionaryDao.insertList(pojos);
    }

    public int update(SysDictionary pojo){
        SysUser user= CommUtil.getCurUser();
        pojo.setUpdateTime(TimeUtil.getNowTimestamp());
        pojo.setUpdatorId(user.getId());
        return sysDictionaryDao.update(pojo);
    }

    public List<SysDictionary> selectDic(SysDictionary pojo){
        return sysDictionaryDao.selectDicByPid(pojo);
    }
}
